const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const {
    CleanWebpackPlugin
} = require("clean-webpack-plugin");
const Happypack = require("happypack");
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
    // entry: "./src/index.js",
    entry: {
        index: "./src/index.js",
        other: "./src/other.js",
    },
    output: {
        filename: "js/[name].[hash:8].js",
        path: path.resolve(__dirname, "dist"),
    },
    plugins: [
        new HtmlWebpackPlugin({
            hash: true,
            filename: "index.html",
            template: "./src/index.html",
        }),
        new CleanWebpackPlugin(),
        new MiniCSSExtractPlugin({
            filename: "css/bundle.css",
        }),
        new webpack.IgnorePlugin(/\.\/locale/, /moment/),
        // new webpack.DllReferencePlugin({
        //     manifest: path.resolve(__dirname, "dist", "manifest.json"),
        // }),
        new Happypack({
            id: "js",
            use: ["babel-loader"],
        }),
    ],
    module: {
        noParse: /jquery/,
        rules: [{
                test: /\.css$/,
                use: [MiniCSSExtractPlugin.loader, "css-loader"],
            },
            {
                test: /\.js$/,
                use: "Happypack/loader?id=js",
                include: /src/,
                exclude: /node_modules/,
            }
        ],
    },
};